/**
  ******************************************************************************
  * File Name          : pid.h
  * Description        : pid计算相关
  ******************************************************************************
  */
#ifndef __PID_H__
#define __PID_H__

typedef struct __PID_Regulator_t
{
	float kp;
	float ki;
	float kd;
	float outputMax;
	
	float ref;
	float fdb;
	float err[2];
	float sum;
	float sumMax;
	
	float output;
	
	
	void (*Calc)(struct __PID_Regulator_t *pid);

} PID_Regulator_t;

#define MOTOR_SPD_PID_DEFAULT \
{\
	-50,\
	0,\
	0,\
	3600\
}

#define MOTOR_POS_PID_DEFAULT \
{\
	0,\
	0,\
	0,\
	1000\
}

#define BALANCE_SPD_PID_DEFAULT \
{\
	100,\
	0.2,\
	-0.1,\
	3600\
}

#define BALANCE_POS_PID_DEFAULT \
{\
	-100,\
	0,\
	-80,\
	3599\
}

void PID_Calc(PID_Regulator_t *pid);

#endif
